<?php

$id = empty($_GET['id']) ? 0 : intval($_GET['id']);
if($id > 0){
	$oRole = new Role();
	$roleinfo = $oRole->get_row($id, '*');
	$roleinfo['setting'] = @unserialize($roleinfo['setting']);
	$_menus = @unserialize($roleinfo['menus']);
	$_powers = @unserialize($roleinfo['powers']);
	$_access = @unserialize($roleinfo['access']);
}else{
	$roleinfo = array(
		'setting'	=> array(),
		'level'		=> 0,
	);
	$_menus = array();
	$_powers = array();
	$_access = array();
}

$roleinfo['access'] = make_checkbox_group('access', Statics::$access_arr, $_access);
$roleinfo['level_options'] = make_options(Statics::$manager_level_arr, true, $roleinfo['level']);

$_f_menus = cache_read('menus.php');
$menu_tree = make_role_ul($_f_menus['menu_tree'], $_menus, $_powers);
$roleinfo['menu_tree'] = $menu_tree;

$vars['info'] = $roleinfo;
?>